package com.qs.eggs.temp;

import android.app.Activity;
import android.content.Context;

import com.qpg.paylib.AliPayAPI;
import com.qpg.paylib.AliPayReq;
import com.qpg.paylib.PayAPI;
import com.qpg.paylib.WechatPayReq;
import com.qs.eggs.Constants;

/**
 * Created by Administrator on 2017/5/23.
 */

public class Temp {


    //支付宝支付
    public static void AliPay(Activity activity){
        // step 1 create config for ali pay
        AliPayAPI.Config config = new AliPayAPI.Config.Builder()
                .setRsaPrivate(Constants.PRIVATEKEY) // rsa private key from partner (pkcs8 format)
                .setRsaPublic(Constants.PRIVATEKEY)//ali rsa public key
                .setPartner(Constants.Partner) //set partner
                .setSeller(Constants.Seller) //set partner seller accout
                .create();

        //step 2 create reqeust for ali
        AliPayReq aliPayReq = new AliPayReq.Builder()
                .with(activity)//Activity instance
                .apply(config)// the above custome config
                .setOutTradeNo("no12335357745")//set unique trade no
                .setPrice("0.01")//set price
                .setSubject("蛋")//set order subject
                .setBody("鸡蛋")//set order detail
                .setCallbackUrl("www.baidu.com")//set callback for pay reqest
                .create()//
                .setOnAliPayListener(null);//

        //step 3 send the request for ali pay
        PayAPI.getInstance().sendPayRequest(aliPayReq);
    }


    //微信支付
    public static void WXPay(Activity activity){
        WechatPayReq wechatPayReq = new WechatPayReq.Builder()
                .with(activity) //activity instance
                .setAppId(Constants.WXPay_APPID) //wechat pay AppID
                .setPartnerId(Constants.WXPay_mch_id)//wechat pay partner id
                .setPrepayId("")//pre pay id
//								.setPackageValue(wechatPayReq.get)//"Sign=WXPay"
                .setNonceStr("")
                .setTimeStamp("")//time stamp
                .setSign("")//sign
                .create();
        //2. send the request with wechat pay
        PayAPI.getInstance().sendPayRequest(wechatPayReq);
    }
}


